/**
 * <p>Title: ServiceZM93.java</p>
 * <p>Description: 生产问题</p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 梁琦
 * @version 1.0
 * <pre>Histroy:
 *          2012-11-12 上午05:12:40  梁琦  Create
 *</pre>
 */
package com.baosight.sczx.zm.service;

import com.baosight.sczx.common.zm.cInterface.cs.InitialData;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.threadlocal.UserSession;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.basetools.StaticTools;
import com.baosight.sczx.zm.domain.ZM93;
import com.baosight.sczx.common.zm.cInterface.IndexConfiger;

/**
 * <p>Title: ServiceZM93.java</p>
 * <p>Description: 生产问题</p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 梁琦
 * @version 1.0
 * <pre>Histroy:
 *          2012-11-12 上午06:27:44  梁琦  Create
 *</pre>
 */
public class ServiceZM93 extends ServiceEPBase {
	
	/**
	 * 初始化
	 * <p>Function: initLoad</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZM93</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-11-12 上午05:12:40 梁琦
	 * </p>
	 *
	 */
	public EiInfo initLoad(EiInfo inInfo)
	{
		inInfo.addBlock(EiConstant.resultBlock).set("showCount", "true");//如果不加这个，翻页的统计和显示是错误的
		EiInfo outInfo = this.query(inInfo);
		return outInfo;
	}
	
	/**
	 * 查询
	 * <p>Function: query</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZM93</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-11-12 上午05:12:40 梁琦
	 * </p>
	 *
	 */
	public EiInfo query(EiInfo inInfo)
	{		
		EiInfo inInfo1 = new EiInfo();
		EiInfo inInfo2 = new EiInfo();
		EiInfo inInfo3 = new EiInfo();
		
		if(!"是".equals(IndexConfiger.getInstance().getIsLeader()))
		{ 
			String org=UserSession.getInSessionProperty("orgCode").toString();	
			StaticTools.setQueryParameters(inInfo1, "fdCreateDepartment", org, true);
			StaticTools.setQueryParameters(inInfo2, "fdOrgId",org,true);//添加查询条件
			StaticTools.setQueryParameters(inInfo3, "fdOrgId",org,true);//添加查询条件
		}		
		String userid=UserSession.getUserId().toString();
		StaticTools.setQueryParameters(inInfo1, "fdUserId",userid,true);//添加查询条件
		EiInfo outInfo = new EiInfo();
		ZM93 zm93 = new ZM93();
		
		StaticTools.setQueryParameters(inInfo1, "fdStatus", "1", true);//添加查询条件
		inInfo1.addBlock("result").set("showCount", "true");
		outInfo = super.query(inInfo1, "ZM93.query", zm93);
		
		StaticTools.setQueryParameters(inInfo2, "fdStatus", "2", true);//添加查询条件
		StaticTools.setQueryParameters(inInfo2, "fdUserId",userid,true);//添加查询条件
		inInfo2.addBlock("resultNotfeedback").set("showCount", "true");
		outInfo.addBlock(super.query(inInfo2, "ZM93.query", zm93, false, null, EiConstant.queryBlock, "resultNotfeedback", "resultNotfeedback").getBlock("resultNotfeedback"));

		StaticTools.setQueryParameters(inInfo3, "fdStatus", "3", true);//添加查询条件
		StaticTools.setQueryParameters(inInfo3, "fdUserId",userid,true);//添加查询条件
		inInfo3.addBlock("resultNotchecked").set("showCount", "true");
		outInfo.addBlock(super.query(inInfo3, "ZM93.query", zm93, false, null, EiConstant.queryBlock, "resultNotchecked", "resultNotchecked").getBlock("resultNotchecked"));

		outInfo.set("num1", outInfo.getBlock("result").get(EiConstant.countStr));
		outInfo.set("num2", outInfo.getBlock("resultNotfeedback").get(EiConstant.countStr));
		outInfo.set("num3", outInfo.getBlock("resultNotchecked").get(EiConstant.countStr));
		
		outInfo.addBlock(InitialData.getInstance().getEiBlockByNo("cmes.cp.problemType"));//问题类型
		outInfo.addBlock(InitialData.getInstance().getEiBlockByNo("cmes.cp.problemLevel"));//问题级别
		outInfo.addBlock(InitialData.getInstance().getEiBlockByNo("cmes.cp.problemOrigin"));//问题来源
		outInfo.set("leader", IndexConfiger.getInstance().getIsLeader());
		return outInfo;
	}

	
}